import os

import pandas as pd
from collections import defaultdict

mapper = {'ABC News': 'Left-Center', 'Al Jazeera English': 'Center', 'Associated Press': 'Center', 'Axios': 'Center', 'Bloomberg': 'Center', 'Breitbart News': 'Right', 'Business Insider': 'Center', 'Buzzfeed': 'Left-Center', 'CBS News': 'Left-Center', 'CNBC': 'Center', 'CNN': 'Left-Center', 'Fortune': 'Not-Rated', 'Fox News': 'Right-Center', 'Mashable': 'Left', 'MSNBC': 'Left', 'National Review': 'Right', 'NBC News': 'Left-Center', 'New York Magazine': 'Left', 'Newsweek': 'Left-Center', 'Politico': 'Left-Center', 'Reuters': 'Center', 'The American Conservative': 'Right-Center', 'The Hill': 'Center', 'The Huffington Post': 'Left', 'The New York Times': 'Left-Center', 'The Verge': 'Left-Center', 'The Wall Street Journal': 'Center', 'The Washington Post': 'Left-Center', 'The Washington Times': 'Right-Center', 'Time': 'Left-Center', 'USA Today': 'Center', 'Vice News': 'Left', 'Wired': 'Not-Rated'}

converter = {"Abc News": "ABC News", "Cnbc": "CNBC", "Cnn": "CNN", "Msnbc": "MSNBC", "Nbc News": "NBC News", "Cbs News": "CBS News", "Usa Today": "USA Today"}

records = defaultdict(int)
images = os.listdir("./../data/images/")
for image in images:
    outlet = image.split("_")[0]
    outlet = outlet.split("-")
    outlet = [token.capitalize() for token in outlet]
    outlet = " ".join(outlet)
    if outlet in converter:
        outlet = converter[outlet]
    records[outlet] += 1

outlets = sorted(records.keys())
for outlet in outlets:
    print(outlet)
    #print(outlet, records[outlet])
    #print(records[outlet])
    # print(mapper[outlet])
